

//
//  DataHandle.m
//  TT
//
//  Created by lanou3g on 15/6/6.
//  Copyright (c) 2015年 苏红召. All rights reserved.


#import "DataHandle.h"
#import "AFNetworking.h"
#import "DuanZi.h"
#import "MBProgressHUD+MJ.h"
#define DUANZI @"http://ic.snssdk.com/neihan/stream/category/data/v2"
static  DataHandle *dataHandle = nil;

@implementation DataHandle

+(DataHandle *)createDataHandle
{
    
    static dispatch_once_t once;
    dispatch_once(&once, ^{
        dataHandle = [[DataHandle alloc] init];
        [dataHandle getnetdata];
    });

    return dataHandle;
    
}
-(void)rloadMyDataWithTableView:(UITableView *)tableView{
    [tableView reloadData];
}

-(void)getnetdata{
    AFHTTPRequestOperationManager *manger = [[AFHTTPRequestOperationManager alloc]init];
    NSMutableDictionary *dic = [NSMutableDictionary new];
    dic[@"tag"] = @"joke";
    dic[@"iid"] = @2696890811;
    dic[@"min_time"] = @1433508392;
    dic[@"category_id"] = @1;
    dic[@"count"] = @30;
    [manger GET:DUANZI parameters:dic success:^(AFHTTPRequestOperation *operation, id responseObject) {
  
        NSMutableArray * array = [NSMutableArray new];
        NSArray *dataarr = responseObject[@"data"][@"data"];
        for (int i = 0; i < dataarr.count; i ++) {
            DuanZi *duanzi = [DuanZi new];
            [duanzi setValuesForKeysWithDictionary:((responseObject[@"data"][@"data"])[i])[@"group"]];
            [array addObject:duanzi];
        }
      
        self.array = array;
        _tip = responseObject[@"data"][@"tip"];
        
     
     [MBProgressHUD showSuccess:[NSString stringWithFormat:@"为您刷新%@条",_tip]];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
    }];
    
    
}
    

@end
